package com.xxgc.helloword.config;

import com.xxgc.helloword.interceptor.JWTInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;

//拦截器配置
public class Interceptor implements WebMvcConfigurer {
    public void addInterceptors(InterceptorRegistry registry){
        //swagger相关
        ArrayList<String> swagger = new ArrayList<>();
        swagger.add("/*.html");
        swagger.add("/swagger-resources/**");
        swagger.add("/webjars/**");
        swagger.add("/v2/**");
        swagger.add("/swagger-ui.html/**");

        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/**")//需要进行token验证的
                .excludePathPatterns("/login/namePassLogin")//旅行的
                .excludePathPatterns(swagger);//swagger相关
    }
}
